﻿using System.Data.Entity;
using RotaractProjectCalendar.Models;
using System.Data.Entity.ModelConfiguration.Conventions;
using Microsoft.AspNet.Identity.EntityFramework;

namespace RotaractProjectCalendar.DataAccessLayer
{
    public class ClubAccount : IdentityUser
    {
        public int ClubId { get; set; }
        public virtual Club Club { get; set; }
    }

    public class CalendarContext : IdentityDbContext<ClubAccount>
    {
        public CalendarContext() : base("CalendarContext")
        {
        }

        public DbSet<Club> Clubs { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Coordinator> Coordinators { get; set; }
        public DbSet<City> Cities { get; set; }
        
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            modelBuilder.Entity<Coordinator>().HasRequired(c => c.Club).WithMany().WillCascadeOnDelete(false);
        }
    }
}